<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>范例</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reflection.constants.html">预定义常量</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reflection.extending.html">扩展</a></div>
 <div class="up"><a href="book.reflection.html">反射</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="reflection.examples" class="chapter">
 <h1>范例</h1>

 <p class="para">
  在反射文档中存在很多例子，通常位于每个类的 __construct 文档中。
 </p>
 <div class="example" id="example-5081">
  <p><strong>Example #1 Shell 里的一个反射例子（一个终端）</strong></p>
  <div class="example-contents">
<div class="shellcode"><pre class="shellcode">$ php --rf strlen
$ php --rc finfo
$ php --re json
$ php --ri dom</pre>
</div>
  </div>

  <div class="example-contents"><p>以上例程的输出类似于：</p></div>
  <div class="example-contents screen">
<div class="cdata"><pre>
Function [ &lt;internal:Core&gt; function strlen ] {

  - Parameters [1] {
    Parameter #0 [ &lt;required&gt; $str ]
  }
}

Class [ &lt;internal:fileinfo&gt; class finfo ] {

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [0] {
  }

  - Methods [4] {
    Method [ &lt;internal:fileinfo, ctor&gt; public method finfo ] {

      - Parameters [2] {
        Parameter #0 [ &lt;optional&gt; $options ]
        Parameter #1 [ &lt;optional&gt; $arg ]
      }
    }

    Method [ &lt;internal:fileinfo&gt; public method set_flags ] {

      - Parameters [1] {
        Parameter #0 [ &lt;required&gt; $options ]
      }
    }

    Method [ &lt;internal:fileinfo&gt; public method file ] {

      - Parameters [3] {
        Parameter #0 [ &lt;required&gt; $filename ]
        Parameter #1 [ &lt;optional&gt; $options ]
        Parameter #2 [ &lt;optional&gt; $context ]
      }
    }

    Method [ &lt;internal:fileinfo&gt; public method buffer ] {

      - Parameters [3] {
        Parameter #0 [ &lt;required&gt; $string ]
        Parameter #1 [ &lt;optional&gt; $options ]
        Parameter #2 [ &lt;optional&gt; $context ]
      }
    }
  }
}

Extension [ &lt;persistent&gt; extension #23 json version 1.2.1 ] {

  - Constants [10] {
    Constant [ integer JSON_HEX_TAG ] { 1 }
    Constant [ integer JSON_HEX_AMP ] { 2 }
    Constant [ integer JSON_HEX_APOS ] { 4 }
    Constant [ integer JSON_HEX_QUOT ] { 8 }
    Constant [ integer JSON_FORCE_OBJECT ] { 16 }
    Constant [ integer JSON_ERROR_NONE ] { 0 }
    Constant [ integer JSON_ERROR_DEPTH ] { 1 }
    Constant [ integer JSON_ERROR_STATE_MISMATCH ] { 2 }
    Constant [ integer JSON_ERROR_CTRL_CHAR ] { 3 }
    Constant [ integer JSON_ERROR_SYNTAX ] { 4 }
  }

  - Functions {
    Function [ &lt;internal:json&gt; function json_encode ] {

      - Parameters [2] {
        Parameter #0 [ &lt;required&gt; $value ]
        Parameter #1 [ &lt;optional&gt; $options ]
      }
    }
    Function [ &lt;internal:json&gt; function json_decode ] {

      - Parameters [3] {
        Parameter #0 [ &lt;required&gt; $json ]
        Parameter #1 [ &lt;optional&gt; $assoc ]
        Parameter #2 [ &lt;optional&gt; $depth ]
      }
    }
    Function [ &lt;internal:json&gt; function json_last_error ] {

      - Parameters [0] {
      }
    }
  }
}

dom

DOM/XML =&gt; enabled
DOM/XML API Version =&gt; 20031129
libxml Version =&gt; 2.7.3
HTML Support =&gt; enabled
XPath Support =&gt; enabled
XPointer Support =&gt; enabled
Schema Support =&gt; enabled
RelaxNG Support =&gt; enabled
</pre></div>
  </div>
 </div>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="reflection.constants.html">预定义常量</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="reflection.extending.html">扩展</a></div>
 <div class="up"><a href="book.reflection.html">反射</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
